<?php

namespace backend\modules\logs\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\AliCarinfoGetLog as AliCarinfoGetLogModel;

/**
 * AliCarinfoGetLog represents the model behind the search form about `\common\models\AliCarinfoGetLog`.
 */
class AliCarinfoGetLog extends AliCarinfoGetLogModel
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'success', 'type', 'uid', 'created_at'], 'integer'],
            [['url', 'request_file_url', 'request_djzs_str', 'request_hgz_text', 'request_fpzw_str', 'car_type', 'car_model', 'vin', 'chisses_number', 'engine_number', 'car_color', 'registration_certificate_number', 'initial_registration_time', 'new_plate_number', 'register_date', 'license_driver', 'invoice_created_date', 'invoice_unit', 'invoice_number', 'request_id', 'config_str', 'resp_body', 'o_id', 'plate_num', 'vehicle_type', 'owner', 'use_character', 'addr', 'model', 'engine_num', 'issue_date', 'appproved_passenger_capacity', 'approved_load', 'file_no', 'gross_mass', 'inspection_record', 'overall_dimension', 'traction_mass', 'unladen_mass', 'RtnCode', 'resultCode', 'resultMsg', 'invoiceName', 'invoiceResult', 'invoicefalseCode', 'isFree', 'invoiceDataCode', 'invoiceNumber', 'billingTime', 'machineCode', 'checkCode', 'result', 'ret_code', 'comment', 'data', 'Code', 'Message', 'RequsetId', 'fpdm', 'fphm', 'kprq', 'num', 'xhdwmc'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = AliCarinfoGetLogModel::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        $query->andFilterWhere([
            'id' => $this->id,
            'success' => $this->success,
            'type' => $this->type,
            'uid' => $this->uid,
            'created_at' => $this->created_at,
        ]);

        $query->andFilterWhere(['like', 'url', $this->url])
            ->andFilterWhere(['like', 'request_file_url', $this->request_djzs_str])
            ->andFilterWhere(['like', 'request_djzs_str', $this->request_djzs_str])
            ->andFilterWhere(['like', 'request_hgz_text', $this->request_hgz_text])
            ->andFilterWhere(['like', 'request_fpzw_str', $this->request_fpzw_str])
            ->andFilterWhere(['like', 'car_type', $this->car_type])
            ->andFilterWhere(['like', 'car_model', $this->car_model])
            ->andFilterWhere(['like', 'vin', $this->vin])
            ->andFilterWhere(['like', 'chisses_number', $this->chisses_number])
            ->andFilterWhere(['like', 'engine_number', $this->engine_number])
            ->andFilterWhere(['like', 'car_color', $this->car_color])
            ->andFilterWhere(['like', 'registration_certificate_number', $this->registration_certificate_number])
            ->andFilterWhere(['like', 'initial_registration_time', $this->initial_registration_time])
            ->andFilterWhere(['like', 'new_plate_number', $this->new_plate_number])
            ->andFilterWhere(['like', 'register_date', $this->register_date])
            ->andFilterWhere(['like', 'license_driver', $this->license_driver])
            ->andFilterWhere(['like', 'invoice_created_date', $this->invoice_created_date])
            ->andFilterWhere(['like', 'invoice_unit', $this->invoice_unit])
            ->andFilterWhere(['like', 'invoice_number', $this->invoice_number])
            ->andFilterWhere(['like', 'request_id', $this->request_id])
            ->andFilterWhere(['like', 'config_str', $this->config_str])
            ->andFilterWhere(['like', 'resp_body', $this->resp_body])
            ->andFilterWhere(['like', 'o_id', $this->o_id])
            ->andFilterWhere(['like', 'plate_num', $this->plate_num])
            ->andFilterWhere(['like', 'vehicle_type', $this->vehicle_type])
            ->andFilterWhere(['like', 'owner', $this->owner])
            ->andFilterWhere(['like', 'use_character', $this->use_character])
            ->andFilterWhere(['like', 'addr', $this->addr])
            ->andFilterWhere(['like', 'model', $this->model])
            ->andFilterWhere(['like', 'engine_num', $this->engine_num])
            ->andFilterWhere(['like', 'issue_date', $this->issue_date])
            ->andFilterWhere(['like', 'appproved_passenger_capacity', $this->appproved_passenger_capacity])
            ->andFilterWhere(['like', 'approved_load', $this->approved_load])
            ->andFilterWhere(['like', 'file_no', $this->file_no])
            ->andFilterWhere(['like', 'gross_mass', $this->gross_mass])
            ->andFilterWhere(['like', 'inspection_record', $this->inspection_record])
            ->andFilterWhere(['like', 'overall_dimension', $this->overall_dimension])
            ->andFilterWhere(['like', 'traction_mass', $this->traction_mass])
            ->andFilterWhere(['like', 'unladen_mass', $this->unladen_mass])
            ->andFilterWhere(['like', 'RtnCode', $this->RtnCode])
            ->andFilterWhere(['like', 'resultCode', $this->resultCode])
            ->andFilterWhere(['like', 'resultMsg', $this->resultMsg])
            ->andFilterWhere(['like', 'invoiceName', $this->invoiceName])
            ->andFilterWhere(['like', 'invoiceResult', $this->invoiceResult])
            ->andFilterWhere(['like', 'invoicefalseCode', $this->invoicefalseCode])
            ->andFilterWhere(['like', 'isFree', $this->isFree])
            ->andFilterWhere(['like', 'invoiceDataCode', $this->invoiceDataCode])
            ->andFilterWhere(['like', 'invoiceNumber', $this->invoiceNumber])
            ->andFilterWhere(['like', 'billingTime', $this->billingTime])
            ->andFilterWhere(['like', 'machineCode', $this->machineCode])
            ->andFilterWhere(['like', 'checkCode', $this->checkCode])
            ->andFilterWhere(['like', 'result', $this->result])
            ->andFilterWhere(['like', 'ret_code', $this->ret_code])
            ->andFilterWhere(['like', 'comment', $this->comment])
            ->andFilterWhere(['like', 'data', $this->data])
            ->andFilterWhere(['like', 'Code', $this->Code])
            ->andFilterWhere(['like', 'Message', $this->Message])
            ->andFilterWhere(['like', 'fpdm', $this->fpdm])
            ->andFilterWhere(['like', 'fphm', $this->fphm])
            ->andFilterWhere(['like', 'kprq', $this->kprq])
            ->andFilterWhere(['like', 'num', $this->num])
            ->andFilterWhere(['like', 'xhdwmc', $this->xhdwmc])
            ->andFilterWhere(['like', 'RequsetId', $this->RequsetId]);

        return $dataProvider;
    }
}
